package com.ymatou.iapi.optrade.parameter.enums;

import java.util.Map;

import com.google.common.collect.Maps;

/**
 * Created by huxiao on 2018/1/8.
 */
public enum OrderStatusEnum {

	// 未付款
	ORDER_ESTABLISH(1),

	// 已付款，待接单
	ACCOUNT_PAID(2),

	// 已发货
	SHIPPED(3),

	// 确认收货
	RECEIVED(4),

	// 买家取消订单
	USER_ACCEPT_CANCEL(12),

	// 卖家取消订单
	SELLER_ACCEPT_CANCEL(13),

	// 补款中
	APPLY_FOR_POSTPAY(16),

	// 已接单
	SELLER_ACCEPT(17),

	// 系统自动取消
	SYSTEM_CANCEL(18)

	;

	private static final Map<Integer, OrderStatusEnum> maps = Maps.newHashMap();

	static {
		for (OrderStatusEnum orderStatusEnum : OrderStatusEnum.values()) {
			maps.put(orderStatusEnum.getCode(), orderStatusEnum);
		}
	}

	int code;

	OrderStatusEnum(int code) {
		this.code = code;
	}

	public static OrderStatusEnum findByCode(Integer code) {
		OrderStatusEnum orderStatusEnum = maps.get(code);
		if (null == orderStatusEnum) {
			throw new IllegalArgumentException(
					"OrderStatusEnum not found,code:" + code);
		}
		return orderStatusEnum;
	}

	public int getCode() {
		return code;
	}
}
